package com.zhisheng.day16_echarts.controller;

import com.zhisheng.day16_echarts.pojo.Pie;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@RestController
@CrossOrigin // 允许前端跨域请求
public class MyController {


    @GetMapping("getPieDate")
    public List<Pie> getPieDate(){
        List<Pie> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 1; i <= 5; i++) {
            int randomCode = random.nextInt(1, 101);
            list.add(new Pie("张"+i,randomCode));
        }
        return list;
    }

}
